/*
 * Gsoft开发框架
 * Copyright 2015-2020 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.itcs.app.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.itcs.app.service.QueryRechargeService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 充值记录
 * @author LiuPeng
 * @date 2017年12月15日
 *  
 */
@Api(value = "充值记录controller", tags = { "充值记录操作接口" })
@RestController
@RequestMapping("/recharge")
public class RechargeController {
	private static final Logger logger=LoggerFactory.getLogger(RechargeController.class);
	@Autowired
	private QueryRechargeService queryRecharge;
	/** 
	 * 充值记录
	 * 查询表名：user_rechange_op_jnl
	 * @param request
	 * @param response
	 * @return 
	 */
	@ApiOperation("充值记录")
	@PostMapping("/findRechargeList")
	public String findRechargeList(HttpServletRequest request, HttpServletResponse response,
			@RequestParam(name="userId",defaultValue="1",required = true) Long id,
			@RequestParam(name="pageSize",defaultValue="1",required = true) Integer pageSize,
			@RequestParam(name="pageIndex",defaultValue="1",required = true) Integer pageIndex
			/*@ApiParam(name = "userId", value = "用户id", required = true) Long id,
			@ApiParam(name = "pageSize", value = "每页条数", required = true) Integer pageSize,
			@ApiParam(name = "pageIndex", value = "当前页数", required = true) Integer pageIndex*/) {
   //起始行数
		int pageStart=(pageIndex-1)* pageSize;
		Map<String,Object> paramMap=new HashMap<String,Object>();
		paramMap.put("userId", id);
		paramMap.put("pageSize", pageSize);
		paramMap.put("pageStart", pageStart);
		List<Map<String,Object>> qryRecharge=queryRecharge.qryList(paramMap);
		int count=queryRecharge.getCount((Long)id);
		logger.info("qryRecharge==="+qryRecharge);
		logger.info("count==="+count);
		if(qryRecharge.size()>0){
			//返回结果
		}else{
		//查询无记录	
		}
		
		
		//返回
		/**
		 * 
				{
				  "total": 108,
				  "data": [
				    {
				      "rechargeId": 179,    //充值ID
				      "userId": 3,         
				      "accountId": null, 
				      "orderNo": "170711231828885", //订单号
				      "amount": 100,               //充值金额
				      "balance": null,
				      "pay": 2,                    //
				      "status": 0,
				      "created": 1499786309000
				    },
				    {
				      "rechargeId": 178,
				      "userId": 3,
				      "accountId": null,
				      "orderNo": "170711231820181",
				      "amount": 100,
				      "balance": null,
				      "pay": 1,
				      "status": 0,
				      "created": 1499786300000
				    },
				    {
				      "rechargeId": 177,
				      "userId": 3,
				      "accountId": null,
				      "orderNo": "170711142926978",
				      "amount": 100,
				      "balance": null,
				      "pay": 1,
				      "status": 0,
				      "created": 1499754567000
				    },
				    {
				      "rechargeId": 176,
				      "userId": 3,
				      "accountId": null,
				      "orderNo": "170711142853805",
				      "amount": 100,
				      "balance": null,
				      "pay": 1,
				      "status": 0,
				      "created": 1499754533000
				    },
				    {
				      "rechargeId": 175,
				      "userId": 3,
				      "accountId": null,
				      "orderNo": "170621112916257",
				      "amount": 1,
				      "balance": null,
				      "pay": 2,
				      "status": 0,
				      "created": 1498015756000
				    }
				  ],
				  "code": 200
				}

		 */
		return "{\r\n" + 
				"  \"total\": 108,\r\n" + 
				"  \"data\": [\r\n" + 
				"    {\r\n" + 
				"      \"rechargeId\": 179,    //充值ID\r\n" + 
				"      \"userId\": 3,         \r\n" + 
				"      \"accountId\": null, \r\n" + 
				"      \"orderNo\": \"170711231828885\", //订单号\r\n" + 
				"      \"amount\": 100,               //充值金额\r\n" + 
				"      \"balance\": null,\r\n" + 
				"      \"pay\": 2,                    //\r\n" + 
				"      \"status\": 0,\r\n" + 
				"      \"created\": 1499786309000\r\n" + 
				"    },\r\n" + 
				"    {\r\n" + 
				"      \"rechargeId\": 178,\r\n" + 
				"      \"userId\": 3,\r\n" + 
				"      \"accountId\": null,\r\n" + 
				"      \"orderNo\": \"170711231820181\",\r\n" + 
				"      \"amount\": 100,\r\n" + 
				"      \"balance\": null,\r\n" + 
				"      \"pay\": 1,\r\n" + 
				"      \"status\": 0,\r\n" + 
				"      \"created\": 1499786300000\r\n" + 
				"    },\r\n" + 
				"    {\r\n" + 
				"      \"rechargeId\": 177,\r\n" + 
				"      \"userId\": 3,\r\n" + 
				"      \"accountId\": null,\r\n" + 
				"      \"orderNo\": \"170711142926978\",\r\n" + 
				"      \"amount\": 100,\r\n" + 
				"      \"balance\": null,\r\n" + 
				"      \"pay\": 1,\r\n" + 
				"      \"status\": 0,\r\n" + 
				"      \"created\": 1499754567000\r\n" + 
				"    },\r\n" + 
				"    {\r\n" + 
				"      \"rechargeId\": 176,\r\n" + 
				"      \"userId\": 3,\r\n" + 
				"      \"accountId\": null,\r\n" + 
				"      \"orderNo\": \"170711142853805\",\r\n" + 
				"      \"amount\": 100,\r\n" + 
				"      \"balance\": null,\r\n" + 
				"      \"pay\": 1,\r\n" + 
				"      \"status\": 0,\r\n" + 
				"      \"created\": 1499754533000\r\n" + 
				"    },\r\n" + 
				"    {\r\n" + 
				"      \"rechargeId\": 175,\r\n" + 
				"      \"userId\": 3,\r\n" + 
				"      \"accountId\": null,\r\n" + 
				"      \"orderNo\": \"170621112916257\",\r\n" + 
				"      \"amount\": 1,\r\n" + 
				"      \"balance\": null,\r\n" + 
				"      \"pay\": 2,\r\n" + 
				"      \"status\": 0,\r\n" + 
				"      \"created\": 1498015756000\r\n" + 
				"    }\r\n" + 
				"  ],\r\n" + 
				"  \"code\": 200\r\n" + 
				"}\r\n" + 
				"";
	}
	
}
